﻿using System.Data.SqlClient;
using CoreLibrary.Service;

namespace CoreLibrary.Sql.Connection {

    public interface IConnectionProvider : IService {

        /// <summary>
        /// Acquires a connection. This connection must be returned by
        /// calling Release method after use.
        /// </summary>
        /// <returns></returns>
        SqlConnection Acquire();

        /// <summary>
        /// Returns a connection to the provider.
        /// </summary>
        /// <param name="conn"></param>
        void Release(SqlConnection conn);

        /// <summary>
        /// Release all resources held by this provider.
        /// </summary>
        void Close();

        T ExecuteQuery<T> (ISqlQuery<T> query);
        T ExecuteScalar<T>(ISqlScalar<T> scalar);
        T ExecuteUpdate<T>(ISqlUpdator<T> updator);

    }
}